package com.mce.nebula.common;

import java.security.SecureRandom;
import java.util.UUID;

/**
 * UUID生成器，对应Python的make_uuid等函数
 */
public class UuidGenerator {
    
    private static final SecureRandom RANDOM = new SecureRandom();
    
    /**
     * 生成标准UUID
     */
    public static String makeUuid() {
        return UUID.randomUUID().toString().replace("-", "");
    }
    
    /**
     * 生成租户ID
     */
    public static String makeTenantId() {
        return "tenant-" + makeUuid().substring(0, 28);
    }
    
    /**
     * 生成服务ID
     */
    public static String makeServiceId() {
        return makeUuid();
    }
    
    /**
     * 生成随机字符串
     */
    public static String randomString(int length) {
        String chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
        StringBuilder result = new StringBuilder();
        for (int i = 0; i < length; i++) {
            result.append(chars.charAt(RANDOM.nextInt(chars.length())));
        }
        return result.toString();
    }
}





